const cloud = require('wx-server-sdk');

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});

/**
 * 新增用户
 */
exports.main = async (event, context) => {
  console.log('[add_user event]:', event);
  console.log('[add_user context]:', context);

  if (!event.userInfo) {
    return {};
  }

  const db = cloud.database();

  // 新增用户
  return await db.collection('user').add({data: {...event.userInfo}});
}
